import { dialog, app, BrowserWindow, shell } from "electron";
import _ from "lodash";
import { regIpc } from "./index";
import fs from 'fs';
export interface Analyzer {
  id?: number
  name: string
  lang: string
  type: string
  path: string
  selected?: boolean
}

export function init() {
  // var file = "./resources/analyzers.json";
  // const getList = () => {
  //   if (fs.existsSync(file)) {
  //     var str = fs.readFileSync(file).toString();
  //     var json = JSON.parse(str);
  //     return json as { python: string, list: Analyzer[], top: number };
  //   } else {
  //     return { python: "", list: [] as Analyzer[], top: 0 };
  //   }
  // };

  regIpc('get-file', async (args) => {

    const result = await dialog.showOpenDialog({
      properties: ['openFile']
    });

    const text = fs.readFileSync(result.filePaths[0]).toString();

    return { "text": text };
  });



};